package s1.s1_3.milk2;

import java.io.*;
import java.util.*;

/*
ID: huangmingbo
LANG: JAVA
TASK: milk2
*/
public class milk2 {

    public static void main(String[] args) throws IOException {
        try (
                InputStreamReader inputStreamReader = new InputStreamReader(milk2.class.getResourceAsStream(milk2.class.getSimpleName() + ".in"));
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                PrintWriter printWriter = new PrintWriter(new FileWriter(milk2.class.getSimpleName() + ".out"));
        ) {

            TreeMap<Integer, Integer> treeMap = new TreeMap<>();

            // read count
            int farmersCount = Integer.parseInt(bufferedReader.readLine());
            StringTokenizer tokenizer;

            int start, end;
            Integer tmp;
            for (int i = 0; i < farmersCount; i++) {
                tokenizer = new StringTokenizer(bufferedReader.readLine());
                start = Integer.parseInt(tokenizer.nextToken());
                end = Integer.parseInt(tokenizer.nextToken());
                if ((tmp = treeMap.get(start)) == null || tmp < end) {
                    treeMap.put(start, end);
                }
            }

            int lastStart = treeMap.firstEntry().getKey();
            int lastEnd = treeMap.firstEntry().getValue();
            int maxinterval = lastEnd - lastStart;
            int maxinterrupt = 0;
            boolean isFirst = true;

            for (Map.Entry<Integer, Integer> entry : treeMap.entrySet()) {
                if (isFirst) {
                    isFirst = false;
                    continue;
                }

                if (entry.getValue() <= lastEnd) {
                    continue;
                }

                if (entry.getKey() <= lastEnd) {
                    lastEnd = entry.getValue();
                    maxinterval = lastEnd - lastStart > maxinterval ? lastEnd - lastStart : maxinterval;
                    continue;
                }

                maxinterrupt = entry.getKey() - lastEnd > maxinterrupt ? entry.getKey() - lastEnd : maxinterrupt;
                lastStart = entry.getKey();
                lastEnd = entry.getValue();
                maxinterval = lastEnd - lastStart > maxinterval ? lastEnd - lastStart : maxinterval;
            }

            printWriter.println(maxinterval + " " + maxinterrupt);

        }
    }
}
